﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TwitterNameTableAdapters;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int intuserid;
        const int ANONIMUSER = -1; const int ALLUSER = 0;
        MessagesTableAdapter MessageAdapter = new MessagesTableAdapter();
        UsersTableAdapter UserAdapter = new UsersTableAdapter();

        string userid1 = HttpContext.Current.User.Identity.Name.ToString();

        try
        {
            if (userid1 == "")
            {
                GridView1.DataSource = MessageAdapter.GetDataBy_id_for_user(ANONIMUSER);
            }
            else
            {
                intuserid = (int)UserAdapter.ScalarQuery_getUserID(userid1);
                //GridView1.DataSource = MessageAdapter.GetDataWithNames();
                GridView1.DataSource = MessageAdapter.GetDataBy_LIKE(id_user.Text,intuserid);
            }
            GridView1.DataBind();
            //Response.Write("Значение параметра id = " + Request.QueryString["id"]);
        }
        catch (Exception) { ;}
    }
    protected void ManageProducts_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int intuserid;
        const int ANONIMUSER = -1; const int ALLUSER = 0;
        MessagesTableAdapter MessageAdapter = new MessagesTableAdapter();
        UsersTableAdapter UserAdapter = new UsersTableAdapter();

        string userid1 = HttpContext.Current.User.Identity.Name.ToString();

        try
        {
            if (userid1 == "")
            {
                GridView1.DataSource = MessageAdapter.GetDataBy_id_for_user(ANONIMUSER);
            }
            else
            {
                intuserid = (int)UserAdapter.ScalarQuery_getUserID(userid1);
                //GridView1.DataSource = MessageAdapter.GetDataWithNames();
                GridView1.DataSource = MessageAdapter.GetDataBy_LIKE(id_user.Text, intuserid);
            }
            GridView1.DataBind();
            //Response.Write("Значение параметра id = " + Request.QueryString["id"]);
        }
        catch (Exception) { ;}
    }
    protected void Button2_Click(object sender, EventArgs e)
    {

    }
}
